package active.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import active.domain.JwMembershipActive;
import active.service.IJwMembershipActiveService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 入团积极分子Controller
 * 
 * @author ruoyi
 * @date 2024-11-08
 */
@RestController
@RequestMapping("/active/active")
public class JwMembershipActiveController extends BaseController
{
    @Autowired
    private IJwMembershipActiveService jwMembershipActiveService;

    /**
     * 查询入团积极分子列表
     */
    @PreAuthorize("@ss.hasPermi('active:active:list')")
    @GetMapping("/list")
    public TableDataInfo list(JwMembershipActive jwMembershipActive)
    {
        startPage();
        List<JwMembershipActive> list = jwMembershipActiveService.selectJwMembershipActiveList(jwMembershipActive);
        return getDataTable(list);
    }

    /**
     * 导出入团积极分子列表
     */
    @PreAuthorize("@ss.hasPermi('active:active:export')")
    @Log(title = "入团积极分子", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JwMembershipActive jwMembershipActive)
    {
        List<JwMembershipActive> list = jwMembershipActiveService.selectJwMembershipActiveList(jwMembershipActive);
        ExcelUtil<JwMembershipActive> util = new ExcelUtil<JwMembershipActive>(JwMembershipActive.class);
        util.exportExcel(response, list, "入团积极分子数据");
    }

    /**
     * 获取入团积极分子详细信息
     */
    @PreAuthorize("@ss.hasPermi('active:active:query')")
    @GetMapping(value = "/{maId}")
    public AjaxResult getInfo(@PathVariable("maId") Long maId)
    {
        return success(jwMembershipActiveService.selectJwMembershipActiveByMaId(maId));
    }

    /**
     * 新增入团积极分子
     */
    @PreAuthorize("@ss.hasPermi('active:active:add')")
    @Log(title = "入团积极分子", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JwMembershipActive jwMembershipActive)
    {
        return toAjax(jwMembershipActiveService.insertJwMembershipActive(jwMembershipActive));
    }

    /**
     * 修改入团积极分子
     */
    @PreAuthorize("@ss.hasPermi('active:active:edit')")
    @Log(title = "入团积极分子", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JwMembershipActive jwMembershipActive)
    {
        return toAjax(jwMembershipActiveService.updateJwMembershipActive(jwMembershipActive));
    }

    /**
     * 删除入团积极分子
     */
    @PreAuthorize("@ss.hasPermi('active:active:remove')")
    @Log(title = "入团积极分子", businessType = BusinessType.DELETE)
	@DeleteMapping("/{maIds}")
    public AjaxResult remove(@PathVariable Long[] maIds)
    {
        return toAjax(jwMembershipActiveService.deleteJwMembershipActiveByMaIds(maIds));
    }
}
